import { fileURLToPath, URL } from 'node:url'
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'

// 配置SVG依赖插件
import { createSvgIconsPlugin } from 'vite-plugin-svg-icons'
import path from 'path'
//添加mock
import { viteMockServe } from 'vite-plugin-mock'
// https://vitejs.dev/config/

export default defineConfig(({ command }) => {
  return {
    plugins: [
      vue(),
      viteMockServe({
        enable: command === 'serve',
      }),
      createSvgIconsPlugin({
        // Specify the icon folder to be cached
        iconDirs: [path.resolve(process.cwd(), 'src/assets/icons')],
        // Specify symbolId format
        symbolId: 'icon-[dir]-[name]',
      })
    ],
    resolve: {
      alias: {
        '@': fileURLToPath(new URL('./src', import.meta.url)),
        // "@": path.resolve("./src") // 相对路径别名配置，使用 @ 代替 src
      }
    }
  }
})